package org.example.server.goods.mapstruct.snapshot.sku;

import org.example.frw.canal.binlog.entity.GoodsSkuBinlogEntity;
import org.example.server.goods.entity.snapshot.GoodsSkuSnapshotEntity;
import org.example.server.goods.mapstruct.snapshot.BaseConverter;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.factory.Mappers;

@Mapper(componentModel = "spring",nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface GoodsSkuSnapshotConverter extends BaseConverter {
  /**
   * 转换实例
   */
  GoodsSkuSnapshotConverter INSTANCE = Mappers.getMapper(GoodsSkuSnapshotConverter.class);

  @Mapping(target = "id",ignore = true)
  @Mapping(target = "skuId",source = "id")
  @Mapping(target = "createTime", source = "createTime", qualifiedByName = "stringToDate")
  @Mapping(target = "updateTime", source = "updateTime", qualifiedByName = "stringToDate")
  @Mapping(target = "status", source = "status", qualifiedByName = "stringToGoodsStatusEnum")
  GoodsSkuSnapshotEntity toGoodsSkuSnapshotEntity(GoodsSkuBinlogEntity goodsSkuEntity);
}
